package es.tikitaka.dictionary;

import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.SequenceGenerator;
import javax.persistence.Table;

import es.tikitaka.domain.Gol;

/**
 * 
 * @author Saúl Domínguez
 * @since 2010
 * @category PFC
 */

@Entity
@Table(name = "TIPOGOLDIC")
public class TipoGolDic {

	private Integer id;
	private String tipo;
	private Set<Gol> m_goles;

	/**
	 * Constructor por defecto
	 */
	public TipoGolDic() {
		// TODO Auto-generated constructor stub
	}

	/*
	 * getters and setters
	 */

	/**
	 * 
	 * @return id Id del tipo de gol
	 */
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE, generator = "TGOL_GEN")
	@SequenceGenerator(allocationSize = 1, name = "TGOL_GEN", sequenceName = "TGOL_SEQ")
	@Column(name = "X_TGOL", nullable = false, precision = 10, scale = 0)
	public Integer getId() {
		return id;
	}

	/**
	 * 
	 * @param id
	 */
	public void setId(Integer id) {
		this.id = id;
	}

	/**
	 * 
	 * @return tipo Tipo de Gol
	 */
	@Column(name = "TIPO")
	public String getTipo() {
		return tipo;
	}

	/**
	 * 
	 * @param tipo
	 */
	public void setTipo(String tipo) {
		this.tipo = tipo;
	}

	/**
	 * 
	 * @return m_goles Goles de un tipo concreto
	 */
	@OneToMany(mappedBy = "tipoGol", fetch = FetchType.LAZY)
	public Set<Gol> getM_goles() {
		return m_goles;
	}

	/**
	 * 
	 * @param m_goles
	 */
	public void setM_goles(Set<Gol> m_goles) {
		this.m_goles = m_goles;
	}

	/**
	 * Método equals
	 */
	@Override
	public boolean equals(Object obj) {
		if (!(obj instanceof TipoGolDic)) {
			return false;
		}
		if (obj != null) {
			if (this.id == ((TipoGolDic) obj).getId()) {
				return true;
			}
		}
		return false;
	}

	/**
	 * Método hashCode
	 */
	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		return super.hashCode();
	}
}
